<%extends"admin/base.html"%><%block content%>
<div class="layui-card">
      <div class="layui-card-body">
        <table id="LAY-app-promotion" lay-filter="LAY-app-promotion"></table>
        <script type="text/html" id="table-promotion">
          <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
        </script>
      </div>
    </div>
<%endblock%>
<%block script%>
  table.render({
        elem: "#LAY-app-promotion",
        url: "<< url_for('admin.PromotionList') >>",
        method:'post',
        cols: [[
            {field: "Id",title: "ID",sort: !0},
            {field: "name", title: "名字"},
            {field: "title", title: "标题"},
            {field: "by_friend", title: "好友利益"},
            {field: "by_me", title: "我的奖励"},
            {field: "href", title: "推广链接"},
            {field: "startTime",title: "开始时间"},
            {field: "endTime",title: "结束时间"},
            {title: "操作",align: "center",fixed: "right",toolbar: "#table-promotion"}
        ]],
        page: !0,
        limit: 15,
        limits: [10, 15, 20, 25, 30],
        text: {
            none: '暂无相关数据',
            error:'对不起，加载出现异常！'
        }
    }), table.on("tool(LAY-app-promotion)", function (t) {
        e=t.data;
        if("del" === t.event){
            layer.confirm("确定删除此条记录？", function (er) {
            console.log(e);
            $.ajax({
                url: "<< url_for('admin.PromotionDel') >>",
                data:{Id:e.Id},
                success: function(returnData) {
                    if (returnData.status == 1) {
                        table.reload('LAY-app-sitemap');
                        layer.msg('已删除，'+e.title);
                        t.del()
                    }
                    else {
                        layer.msg(e.title+'，'+returnData.info);
                    }
                 }
              });
            })
        }
    })
    $('.layui-nav-child dd').removeClass('layui-this');
    $('#view_admin_promotion').addClass('layui-this');
    $('.layui-nav-tree li').removeClass('layui-nav-itemed');
    $('#admin_system_nav').addClass('layui-nav-itemed');
<%endblock%>